-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add pattern and path to regexp create errors #2477 #2485
base: master
Are you sure you want to change the base?
Conversation
…alidator/ajv into feat-add-informative-regexp-errors
const u = it.opts.unicodeRegExp ? "u" : "" | ||
const regExp = $data ? _`(new RegExp(${schemaCode}, ${u}))` : usePattern(cxt, schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was never using opts.code.regExp
? Is that intentional?
throw new Error(e.message + ' | pattern ' + ${schemaCode} + ' at ' + ${it.errSchemaPath}) | ||
} | ||
})()` | ||
: usePattern(cxt, schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is probably a way to build this with gen.try etc but maybe this is ok? I'm still getting my head around codegen stuff.
What issue does this pull request resolve?
#2477 - Wrap regexp instantiation in try/catch to add pattern and schema path to the error message
What changes did you make?
Wrapped both the regular and codegen'd versions of the pattern keyword regexp creation
Is there anything that requires more attention while reviewing?
Not sure if there is a better way to do the codegen, I did try using gen.try etc but couldn't figure it out.